home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / sudo.postinst < prev    next >
Encoding:
Text File  |  2012-05-23  |  2.2 KB  |  77 lines

  1. #!/usr/bin/perl
  2.  
  3. # remove old link
  4.  
  5. unlink ("/etc/alternatives/sudo") if ( -l "/etc/alternatives/sudo");
  6.  
  7. # make sure we have a sudoers file
  8. if ( ! -f "/etc/sudoers") {
  9.  
  10.     print "No /etc/sudoers found... creating one for you.\n";
  11.  
  12.     open (SUDOERS, "> /etc/sudoers");
  13.     print SUDOERS "# /etc/sudoers\n",
  14.       "#\n",
  15.       "# This file MUST be edited with the 'visudo' command as root.\n",
  16.       "#\n",
  17.       "# See the man page for details on how to write a sudoers file.\n",
  18.       "#\n\nDefaults\tenv_reset\n\n",
  19.       "# Host alias specification\n\n",
  20.       "# User alias specification\n\n",
  21.       "# Cmnd alias specification\n\n",
  22.       "# User privilege specification\nroot\tALL=(ALL) ALL\n\n",
  23.       "# Allow members of group sudo to execute any command\n",
  24.       "# (Note that later entries override this, so you might need to move\n",
  25.           "# it further down)\n",
  26.       "%sudo ALL=(ALL) ALL\n",
  27.       "#\n",
  28.       "#includedir /etc/sudoers.d\n";
  29.     close SUDOERS;
  30.  
  31. }
  32.  
  33. # handle state directory transition from /var/run/sudo to /var/lib/sudo,
  34. # moving any existing content over to avoid re-lecturing existing users
  35. if ( -d "/var/run/sudo") {
  36.     system ('mkdir -p /var/lib/sudo');
  37.     system ('mv /var/run/sudo/* /var/lib/sudo/');
  38.     system ('rmdir /var/run/sudo');
  39. }
  40.  
  41. # make sure sudoers has the correct permissions and owner/group
  42. system ('chown root:root /etc/sudoers');
  43. system ('chmod 440 /etc/sudoers');
  44.  
  45. # must do a remove first to un-do the "bad" links created by previous version
  46. system ('update-rc.d -f sudo remove >/dev/null 2>&1');
  47.  
  48. system ('update-rc.d sudo start 75 2 3 4 5 . >/dev/null');
  49.  
  50. # make sure we have a sudo group
  51.  
  52. exit 0 if getgrnam("sudo"); # we're finished if there is a group sudo
  53.  
  54. $gid = 27;                 # start searcg with gid 27
  55. setgrent;
  56. while (getgrgid($gid)) {
  57.     ++$gid;
  58. }
  59. endgrent;
  60.  
  61. if ($gid != 27) {
  62.     print "On Debian we normally use gid 27 for 'sudo'.\n";
  63.     $gname = getgrgid(27);
  64.     print "However, on your system gid 27 is group '$gname'.\n\n";
  65.     print "Would you like me to stop configuring sudo so that you can change this? [n] "; 
  66.     $ans = <STDIN>;
  67.         if ($ans =~ m/^[yY].*/) {
  68.         print "'dpkg --pending --configure' will restart the configuration.\n\n\n";
  69.         exit 1;
  70.     }
  71. }
  72.  
  73. print "Creating group 'sudo' with gid = $gid\n";
  74. system("groupadd -g $gid sudo");
  75.  
  76. print "";
  77.